package com.brett.frame.learn.sort.exchange;

import com.brett.frame.learn.sort.base.BaseSort;

/**
 * 冒泡排序
 * @author lenovo
 *{@link https://blog.csdn.net/weixin_38333555/article/details/80515605}
 */
public class BubbleSort extends BaseSort {

	public int[] sort(int[] arr) {
		for (int i = arr.length - 1; i >= 0; i--) {
			for (int j = 0; j < i; j++) {
				if (arr[j] > arr[j + 1]) {
					super.exchange(arr, j, j + 1);
				}
			}
		}
		return arr;
	}
}
